package com.ostrich.lib_common.base;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import android.content.Intent;
import android.os.Bundle;

import com.gyf.immersionbar.ImmersionBar;
import com.ostrich.lib_common.R;

public abstract class BaseActivity<VDB extends ViewDataBinding> extends AppCompatActivity {
    protected VDB binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_base);
        binding = DataBindingUtil.setContentView(this,bindLayout());
        ImmersionBar.with(this)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一
                .statusBarColor(R.color.purple_200)//状态栏颜色，不写默认透明色
                .init();


        initView();
        initListener();
        initData();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        binding = null;
    }

    public abstract int bindLayout();
    public  abstract void initView();
    public abstract void initData();
    public abstract void initListener();


    //页面跳转
    public void startActivity(Class class_){
        Intent intent = new Intent(this, class_);
        startActivity(intent);
    }

    //页面跳转传值
    public void startActivityBundle(Class class_,Bundle bundle){
        Intent intent = new Intent(this, class_);
        intent.putExtras(bundle);
        startActivity(intent);
    }
    //.............





}